﻿using DJY.Code;
using System.Threading;
using System.Web.Mvc;

namespace DJY.Web
{
    public class HandlerErrorAttribute : HandleErrorAttribute
    {
        public override void OnException(ExceptionContext context)
        {
            base.OnException(context);
            if (!(context.Exception is ThreadAbortException))
            {
                Logs.Write(Common.ShowException(context.Exception));
            }
            context.ExceptionHandled = true;
            context.HttpContext.Response.StatusCode = 200;
            context.Result = new JsonResult()
            {
                Data = AjaxResult.Fail(Common.ShowException(context.Exception))
            };
        }
    }
}